import os
import fileinput
import sys


if len(sys.argv)<2:
    print('Usage: checksymmetry.py spmatrixfilename ')
    quit()
else:
    print('Parameters OK')

spmfile = sys.argv[1]

spf=fileinput.input(spmfile)

d=dict()

for line in spf:
    ar = line.split()
    if len(line)>1:
        row = int(ar[0])
        col = int(ar[1])
        val = ar[2]
        if row not in d:
            dd=dict()
        else:
            dd=d[row]
        dd[col]=val
        d[row]=dd

for row in d.iterkeys():
    for col in d[row].iterkeys():
#        print(str(row)+' '+str(col))
        if col not in d:
            print('mismatch of row->col')
        else:
            if row not in d[col]:
                print('mismatch of row->col')
            else:
                if not d[row][col]==d[col][row]:
                    err=float(d[row][col])-float(d[col][row])
                    print(str(row)+':'+str(col)+':'+str(err)+':->\n:'+d[row][col]+'\n:'+d[col][row])

spf.close()
